package com.lzwk.app.function;

import lombok.var;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.table.planner.expressions.Collect;
import org.apache.flink.types.Row;
import scala.Array;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @title: GetMixedOrderId
 * @Author Yeaser
 * @Date: 2022/4/22 11:38
 * @Version 1.0
 * Description: TODO
 */
@FunctionHint(output = @DataTypeHint("ROW<id Integer>"))
public class GetMixedOrderId extends TableFunction<Row> {
    public  void eval(String ids) {
        //System.out.println("============================>" + ids);
        if (ids.contains(",")) {
            String[] split = ids.split(",");
            for (String id : split)
                if (id != null) {
                    System.out.println("============================>" +id);
                    collect(Row.of(Integer.parseInt(id)));
                }
        }else {
            if (!"".equals(ids)) {
                collect(Row.of(Integer.parseInt(ids)));
            }
        }
    }

    public static void main(String[] args) {
        String s = "yes,";
        String[] split = s.split("=");
        for (String s1 : split) {
            System.out.println(s1 + "===");
        }
    }
}
